<?php
class NewsAction extends BaseAction{
    function index($articleId){
       //查询新闻
        $sql="select * from newsarticles a inner join newstypes b on a.typeId=b.typeId and articleId={$articleId}";
       $newsArt=M()->query($sql);
       //查询评论
       $getReview=M('reviews')->where("articleId={$articleId}")->select();
        $this->assign('newsArt',$newsArt[0]);
       $this->assign('getReview',$getReview);
        $this->display();
    }
    function news(){
        //添加评论
        $result=M('reviews')->add($_POST);
        if($result>0){
            $this->success("发表评论成功！",__APP__."/News/index/articleId/{$_POST["articleId"]}.html");
        }else{
            $this->success("发表评论失败！",__APP__."/News/index/articleId/{$_POST["articleId"]}.html");
        }
    }
}